package servlet;

import hadoop.hadooputil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @auther 郭天凌
 * @date 2022/3/11
 */
@WebServlet("/demo2")
public class servletdemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String srcpath =req.getParameter("srcpath");
        hadooputil hadoopUtil = new hadooputil();
        String  result  =  hadoopUtil.hadoopRead(srcpath);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw =  resp.getWriter();
        pw.write(result);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
